home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
language
/
dl_exsrc.zoo
/
memavail.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-03
|
658b
|
26 lines
#include <unistd.h>
#include <osbind.h>
#include "membook.h"
long memavail()
{
register struct mem_chunk *r = &_mchunk_free_list;
register unsigned long maxsize = 0, memfree;
register int pagesize;
for (; r; r = r->next)
if (r->size > maxsize)
maxsize = r->size;
if (Sversion() >= 0x1900) /* GEMDOS version >= 0.19, use Mxalloc() */
memfree = Mxalloc(-1L, 2);
else /* GEMDOS version < 0.19, use Malloc() */
memfree = Malloc(-1L);
pagesize = getpagesize();
memfree = (memfree/pagesize) * pagesize;
if (memfree > maxsize)
maxsize = memfree;
return maxsize - sizeof(struct mem_chunk);
}